#include "breathing_led.h"


uint16_t led_cycle=100;


void led_init(){
	//uint16_t freq = 2000;									//频率，有误
  //uint16_t count_period = 1000000/freq;					//周期，有误
  //__HAL_TIM_SetAutoreload(&htim4,count_period-1);			//配置定时器周期 
  //__HAL_TIM_SetCompare(&htim4,TIM_CHANNEL_2, 1000-1);    	//修改比较值，修改占空比
  HAL_TIM_PWM_Start(&htim4,TIM_CHANNEL_2);				//PA8
}


void led_brightness(uint16_t brightness)//范围应该是1~5


{
	brightness=brightness*1999/led_cycle;
	if(brightness>1999){
		brightness=1999;
	}
	 __HAL_TIM_SetCompare(&htim4,TIM_CHANNEL_2, brightness);    	//修改比较值，修改占空比
}